/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataStructures;

import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author Manuel
 */
public class BugData {

    private ArrayList<Bug> bugList;
    private int noOfBugs;

    public BugData(){
        bugList = new ArrayList<Bug>();
    }

    public void addBug(Bug b){
        boolean alreadyExists = false;
        for(int i = 0;i<bugList.size();i++){
            if(bugList.get(i).getIssueID() == b.getIssueID())
                alreadyExists = true;
        }
        if(!alreadyExists)
            bugList.add(b);
        noOfBugs = bugList.size();
    }

    public ArrayList<Bug> getBugList(){
        return bugList;
    }

    public Bug getByDate(Date d){
        int pos = -1;
        for(int i = 0;i<bugList.size();i++){
            if(d.compareTo(bugList.get(i).getCreationDate()) == 0){
                pos = i;
            }
        }
        if( pos != -1)
            return bugList.get(pos);
        else return null;
    }

    public int getNumber(){
        return bugList.size();
    }


}
